package IGU;

import datos.ListaActores;
import datos.ListaDirectores;
import datos.ListaPersonaSimple;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileNameExtensionFilter;
import logica.FuncionesGUI;

/**
 *
 * @author Cristian
 */
public class AgregarPelicula extends javax.swing.JFrame {
    private JFrame ventanaPadre;
    private ListaActores listaReparto = new ListaActores();
    private ListaDirectores listaDirectores = new ListaDirectores();

    private int val;
private String absolutePath;
    /** Creates new form AgregarPelicula */
    public AgregarPelicula() {
        initComponents();
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        JTASinopsis = new javax.swing.JTextArea();
        JTFNombrePelicula = new javax.swing.JTextField();
        JTFNombreOriginaPelicula = new javax.swing.JTextField();
        JTFReparto = new javax.swing.JTextField();
        JTFDirectores = new javax.swing.JTextField();
        JTFGuionista = new javax.swing.JTextField();
        JTFProductora = new javax.swing.JTextField();
        JTFGenero = new javax.swing.JTextField();
        JTFDuracion = new javax.swing.JTextField();
        JTFLanzamiento = new javax.swing.JTextField();
        JTFIdioma = new javax.swing.JTextField();
        JTFSubtitulos = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        JBExaminar = new javax.swing.JButton();
        jFMovieSelector = new javax.swing.JFileChooser();
        jLimagen = new javax.swing.JLabel();
        jBAgregarDirector = new javax.swing.JButton();
        jBAgregarReparto = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        botonAgregarPelicula = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Productora:");
        jLabel1.setName("jLabel1"); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 290, -1, -1));

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Nombre:");
        jLabel3.setName("jLabel3"); // NOI18N
        getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 120, -1, -1));

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Nombre original:");
        jLabel4.setName("jLabel4"); // NOI18N
        getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 160, -1, -1));

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Subtítulos");
        jLabel6.setName("jLabel6"); // NOI18N
        getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 310, 101, -1));

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Sinopsis:");
        jLabel7.setName("jLabel7"); // NOI18N
        getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 340, -1, -1));

        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Idioma:");
        jLabel8.setName("jLabel8"); // NOI18N
        getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 280, -1, -1));

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Lanzamiento (año): ");
        jLabel9.setName("jLabel9"); // NOI18N
        getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 420, -1, -1));

        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("Duracion:");
        jLabel10.setName("jLabel10"); // NOI18N
        getContentPane().add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 370, -1, -1));

        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("Género:");
        jLabel11.setName("jLabel11"); // NOI18N
        getContentPane().add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 320, -1, -1));

        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("Director(es):");
        jLabel12.setName("jLabel12"); // NOI18N
        getContentPane().add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 220, -1, -1));

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("Guionista:");
        jLabel13.setName("jLabel13"); // NOI18N
        getContentPane().add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 250, -1, -1));

        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("Reparto:");
        jLabel14.setName("jLabel14"); // NOI18N
        getContentPane().add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 190, -1, -1));

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        JTASinopsis.setColumns(20);
        JTASinopsis.setRows(5);
        JTASinopsis.setName("JTASinopsis"); // NOI18N
        jScrollPane1.setViewportView(JTASinopsis);

        getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 360, 240, -1));

        JTFNombrePelicula.setName("JTFNombrePelicula"); // NOI18N
        JTFNombrePelicula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFNombrePeliculaActionPerformed(evt);
            }
        });
        getContentPane().add(JTFNombrePelicula, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 120, 190, -1));

        JTFNombreOriginaPelicula.setName("JTFNombreOriginaPelicula"); // NOI18N
        JTFNombreOriginaPelicula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFNombreOriginaPeliculaActionPerformed(evt);
            }
        });
        getContentPane().add(JTFNombreOriginaPelicula, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 150, 190, -1));

        JTFReparto.setName("JTFReparto"); // NOI18N
        JTFReparto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JTFRepartoActionPerformed(evt);
            }
        });
        getContentPane().add(JTFReparto, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 180, 110, -1));

        JTFDirectores.setName("JTFDirectores"); // NOI18N
        getContentPane().add(JTFDirectores, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 220, 110, -1));

        JTFGuionista.setName("JTFGuionista"); // NOI18N
        getContentPane().add(JTFGuionista, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 250, 190, -1));

        JTFProductora.setName("JTFProductora"); // NOI18N
        getContentPane().add(JTFProductora, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 280, 190, -1));

        JTFGenero.setName("JTFGenero"); // NOI18N
        getContentPane().add(JTFGenero, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 320, 190, -1));

        JTFDuracion.setName("JTFDuracion"); // NOI18N
        getContentPane().add(JTFDuracion, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 370, 130, -1));

        JTFLanzamiento.setName("JTFLanzamiento"); // NOI18N
        getContentPane().add(JTFLanzamiento, new org.netbeans.lib.awtextra.AbsoluteConstraints(200, 410, 130, -1));

        JTFIdioma.setName("JTFIdioma"); // NOI18N
        getContentPane().add(JTFIdioma, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 270, 130, -1));

        JTFSubtitulos.setName("JTFSubtitulos"); // NOI18N
        getContentPane().add(JTFSubtitulos, new org.netbeans.lib.awtextra.AbsoluteConstraints(510, 300, 130, -1));

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Agregar Poster:");
        jLabel5.setName("jLabel5"); // NOI18N
        getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 90, -1, -1));

        JBExaminar.setText("Examinar...");
        JBExaminar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        JBExaminar.setName("JBExaminar"); // NOI18N
        JBExaminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                JBExaminarActionPerformed(evt);
            }
        });
        getContentPane().add(JBExaminar, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 130, -1, -1));

        jFMovieSelector.setName("jFMovieSelector"); // NOI18N
        getContentPane().add(jFMovieSelector, new org.netbeans.lib.awtextra.AbsoluteConstraints(708, 530, 14, 20));

        jLimagen.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));
        jLimagen.setName("jLimagen"); // NOI18N
        getContentPane().add(jLimagen, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 90, 120, 160));

        jBAgregarDirector.setText("Agregar");
        jBAgregarDirector.setName("jBAgregarDirector"); // NOI18N
        jBAgregarDirector.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAgregarDirectorActionPerformed(evt);
            }
        });
        getContentPane().add(jBAgregarDirector, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 220, -1, -1));

        jBAgregarReparto.setText("Agregar");
        jBAgregarReparto.setName("jBAgregarReparto"); // NOI18N
        jBAgregarReparto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAgregarRepartoActionPerformed(evt);
            }
        });
        getContentPane().add(jBAgregarReparto, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 180, -1, -1));

        jPanel1.setBackground(new java.awt.Color(51, 51, 51));
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setLayout(null);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Agregar Una Película Nueva");
        jLabel2.setName("jLabel2"); // NOI18N
        jPanel1.add(jLabel2);
        jLabel2.setBounds(270, 40, 200, 17);

        botonAgregarPelicula.setText("Agregar Película");
        botonAgregarPelicula.setName("botonAgregarPelicula"); // NOI18N
        botonAgregarPelicula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarPeliculaActionPerformed(evt);
            }
        });
        jPanel1.add(botonAgregarPelicula);
        botonAgregarPelicula.setBounds(300, 480, 109, 23);

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 730, 550));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void JTFNombrePeliculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFNombrePeliculaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTFNombrePeliculaActionPerformed

    private void JBExaminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JBExaminarActionPerformed
    int returnval = jFMovieSelector.showOpenDialog(this);
    if (returnval == jFMovieSelector.APPROVE_OPTION )
    {
    File file = jFMovieSelector.getSelectedFile();
    jLimagen.setIcon(new ImageIcon(file.getAbsolutePath()));
    System.out.println(file.getAbsolutePath());
            absolutePath = file.getAbsolutePath();
    }
    else
    {
    System.out.println("Operacion Cancelada por el Usuario.");
    }


        // TODO add your handling code here:
    }//GEN-LAST:event_JBExaminarActionPerformed

    private void botonAgregarPeliculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarPeliculaActionPerformed


         listaReparto.imprimirColeccion();
         listaDirectores.imprimirColeccion();

         FuncionesGUI.cargarPeliculaNueva(listaReparto, listaDirectores, JTFNombrePelicula, JTFNombreOriginaPelicula, JTFGuionista, JTFProductora, JTFGenero, JTFDuracion, JTFLanzamiento, JTFIdioma, JTFSubtitulos, JTASinopsis, absolutePath);
         //(ListaPersonaSimple reparto, ListaPersonaSimple directores, JTextField nombre, JTextField nombreOriginal, JTextField guionista, JTextField productora,JTextField genero,JTextField duracion,JTextField lanzamiento,JTextField idioma,JTextField subtitulos,JTextField sinopsis) {

        FuncionesGUI.habilitarVentana(this.ventanaPadre, true, true);
        this.dispose();

    }//GEN-LAST:event_botonAgregarPeliculaActionPerformed

    private void JTFNombreOriginaPeliculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFNombreOriginaPeliculaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTFNombreOriginaPeliculaActionPerformed

    private void JTFRepartoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_JTFRepartoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_JTFRepartoActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
FuncionesGUI.habilitarVentana(this.ventanaPadre, true, true);
        this.dispose();
    }//GEN-LAST:event_formWindowClosing

    private void jBAgregarRepartoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAgregarRepartoActionPerformed


        FuncionesGUI.agregarActorNuevo(JTFReparto.getText(),listaReparto);

        JTFReparto.setText("");

        // TODO add your handling code here:
    }//GEN-LAST:event_jBAgregarRepartoActionPerformed

    private void jBAgregarDirectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAgregarDirectorActionPerformed


        FuncionesGUI.agregarDirectorNuevo(JTFDirectores.getText(),listaDirectores);

        JTFDirectores.setText("");


        // TODO add your handling code here:
    }//GEN-LAST:event_jBAgregarDirectorActionPerformed

    /**
    * @param args the command line arguments
    */

     private void initMyOwnComponents() {


    }

      public JFrame getVentanaPadre()
    {
        return ventanaPadre;
    }
     public void setVentanaPadre(JFrame ventanaPadre)
    {
        this.ventanaPadre = ventanaPadre;
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AgregarPelicula().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton JBExaminar;
    private javax.swing.JTextArea JTASinopsis;
    private javax.swing.JTextField JTFDirectores;
    private javax.swing.JTextField JTFDuracion;
    private javax.swing.JTextField JTFGenero;
    private javax.swing.JTextField JTFGuionista;
    private javax.swing.JTextField JTFIdioma;
    private javax.swing.JTextField JTFLanzamiento;
    private javax.swing.JTextField JTFNombreOriginaPelicula;
    private javax.swing.JTextField JTFNombrePelicula;
    private javax.swing.JTextField JTFProductora;
    private javax.swing.JTextField JTFReparto;
    private javax.swing.JTextField JTFSubtitulos;
    private javax.swing.JButton botonAgregarPelicula;
    private javax.swing.JButton jBAgregarDirector;
    private javax.swing.JButton jBAgregarReparto;
    private javax.swing.JFileChooser jFMovieSelector;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLimagen;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables



}
